<!--#include virtual="/dzps/p1.asp"-->
<script language="JScript" runat="Server">
    function ToObject(json) {
        var o;
        eval("o=" + json);
        return o;
    }

    function toArray(s) {
        var dic = Server.CreateObject("Scripting.Dictionary")
        eval("var a=" + json);
        for (var i = 0; i < a.length; i++) {
            var obj = Server.CreateObject("Scripting.Dictionary")
            for (x in a[i]) obj.Add(x, a[i][x])
            dic.Add(i, obj);
        }
        return dic
    }
</script>
<%
dim action,ret,sql,rs,json
json = request.form
action=Easp.Var("action")

select case action
	case "upf_1_add" 		upf_1_add
	case "upf_1_upd" 		upf_1_upd
	case "upf_1_del" 		upf_1_del
	case "upf_1_lst" 		upf_1_lst
	case "code_add" 		code_add
	case "runr_get" 		runr_get
	case "runr_get_hello" 		runr_get_hello
	case "runr_get0" 		runr_get0
	case "code_del" 		code_del
	case "log1_get" 		log1_get
end select
function upf_1_add()
	dim sqla(10)
	vas "mode","upf_1"
	sqla(0)=cr2("[baseinfo]","mode,name1,name2,name3")
	ret=execsw(sqla)
	rt ret
end function
Function upf_1_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
function upf_1_upd()
	dim sqla(10),ret
	sqla(0)=xg("[baseinfo]","name1,name2,name3","id={id:int}")
	ret=execsw(sqla)
	rt ret	
end function
function upf_1_lst()
	dim i,arr,img0,img1,img2,j
	dim data_id,card_title,card_p,time_show,href
	arr= sql2arr("select id,name1,name2,name3 from baseinfo  where (1=1) and mode='upf_1' order by id desc")

	if ubound(arr)>0 then
		for i=0 to ubound(arr,2)
			data_id=arr(0,i)
			'card_title=arr(1,i)
			card_p=arr(2,i)
			time_show=arr(3,i)
			href="http://124.222.154.144:8383/dzps/yx/upload/"& arr(1,i)		
			echo myjs1("card_upf_1.js","data-id|"& data_id &",card_title|" & card_title  &",card_p|"&   card_p  & " <br>  "  & ",time|" & time_show &",href|" & href)
		next
	end if
end function
function upf_1_count()
	dim i,arr,title_
	sql="select id from baseinfo where (mode='upf_1') and (1=1) and (2=2) and (3=3) and (4=4)"
	echo rc(sql)
end function
function code_del()
	dim ret
	vas "mode","onc_1"
	ret = Easp.Db.Del("[baseinfo]","mode={mode}")
	Easp.Fso.Del "upload/*.c"
	Easp.Fso.DelFile "upload/*.exe"
	Easp.Fso.DelFile "upload/*.out"
	Easp.Fso.DelFile "upload/*.rout"
end function
function code_add()
	dim sqla(10),fname
	fname=cint(Easp.Str.RandomNumber(1, 4000))
	Easp.Fso.CreateFile "upload/"& fname & ".c",val("code")
	vas "mode","onc_1"
	vas "name2",fname
	sqla(0)=cr2("[baseinfo]","mode,name1,name2,name3")
	ret=execsw(sqla)
	rt2 ret,fname
end function
Function runr_get()
	dim sqla(10),out1
	out1 = Easp.Fso.Read("upload/"& val("fname") & ".c")
	echo out1
End Function
Function runr_get_Hello()
	dim sqla(10),out1
	out1 = Easp.Fso.Read(val("fname") & ".c")
	echo out1
End Function
Function runr_get0()
	dim sqla(10),out1
	out1 = Easp.Fso.Read("upload/"& val("fname") )
	echo out1
End Function
Function log1_get()
	dim sql
	sql="select questionDescription from log1  where (1=1) and (id={id:int})"
	s11 sql,"questionDescription"
	echo val("questionDescription")
end function
Function user_typ_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function

Function xd_add2()
	save_html val("log1_id"),val("content")
	rt 1
End Function
Function save_html(log1_id,content)
	dim conn3,rs1
	Set Conn3 = Easp.Db.GetConn
	sql = "select top 1 * from xd_p where log1_id="&log1_id
	Set rs = server.CreateObject("adodb.recordset")
	rs.open sql,conn3,1,3
	if rs.recordcount=0 then
		rs.addnew
	else
	end if
	rs("content")=content
	rs("log1_id")=val("log1_id")
	rs("user_id")=session("user_id")
	rs.update
	rs.Close
	Set rs = Nothing
End Function

function json_help(key,value)
	dim txt
	txt= syh(key)&":"& value
	json_help=txt
end function
'card_post=id,title,cover_path,keywords,add_time,mod_time,pub_time,description,content,views,cat_id,user_id,allow_comment,is_display,is_delete,is_audit,comment_count,view_count,zan_count,cai_count,is_top,log1_id

Function user_typ_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function user_typ_l()
	sql="select id,name1 from baseinfo  where (1=1) and (mode='用户类型')"
	if val("user_typ_search")<>"" then
		vas "likeKey" ,"%{=user_typ_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if
	qry2json(sql)
end function
Function eqi_add()
	dim sqla(10)
	vas hr_1("mode"),"设备类型"
	sqla(0)=cr2("[baseinfo]","name1,mode")
	ret=execsw(sqla)
	rt ret
End Function
Function eqi_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function eqi_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function

Function typ_add()
	dim sqla(10)
	vas hr_1("mode"),"工单类型"
	sqla(0)=cr2("[baseinfo]","name1,mode")
	ret=execsw(sqla)
	rt ret
End Function
Function typ_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function typ_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function typ_l()
	sql="select id,name1 from baseinfo  where (1=1) and (mode='工单类型')"
	if val("typ_search")<>"" then
		vas "likeKey" ,"%{=typ_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if
	qry2json(sql)
end function
Function status_add()
	dim sqla(10)
	vas hr_1("mode"),"工单状态"
	sqla(0)=cr2("[baseinfo]","name1,mode")
	ret=execsw(sqla)
	rt ret
End Function
Function status_upd()
	dim sqla(10)
	vas "id",val(hr_1("id")) 
	sqla(0)=xg2("[baseinfo]","name1","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function status_del()
	dim ret
	ret = Easp.Db.Del("[baseinfo]","id={id:int}")
	rt ret
End Function
Function status_l()
	sql="select id,name1 from baseinfo  where (1=1) and (mode='工单状态')"
	if val("status_search")<>"" then
		vas "likeKey" ,"%{=status_search}%"
		sql=replace(sql,"1=1","name1 like {likeKey}")
	end if
	qry2json(sql)
end function

Function prn_del()
	dim ret
	ret = Easp.Db.Del("[equipment]","id={id:int}")
	rt ret
End Function
Function prn_add()
	dim sqla(10),rc1
	vas "machineNo",val("machineNo")
	rc1= rc("select id from [equipment] where machineNo={machineNo}")
	'val("machineNo")<>"" 用于没有机器号的情况
	if rc1=1 and val("machineNo")<>"" then 
		s1 "select id as id1 from [equipment] where machineNo={machineNo}"
		rt2 0,"machineNo 机器号" & val("machineNo") & " 重复id=" & val("id1")
	else
		sqla(0)=cr2("[equipment]","department,[local],machineNo,equipmentTypeId,ipadr")
		ret=execsw(sqla)
		rt ret		
	end if	
End Function
Function log1_del()
	dim sqla(10),rc1
	ret = Easp.Db.Del("[log1]","id={id:int}")
	ret=execsw(sqla)
	rt ret
End Function
Function log1_add2()
	dim sqla(10)
	sqla(0)=cr2("[log1]","[declare],declareTele,questionDescription,typ,status,repairerId,fxpwd")
	ret=execsw(sqla)
	rt ret
	
	if val("sendmess")="on" then
		vas "repairerId",val("repairerId")
		s1 "select mobile from [user] where id={repairerId}"
		vas "mess_text","收到工单:"& val("questionDescription") & " 来自：" & val("declare") & val("declareTele")  &  "，请及时处理。"
		vas "phone",val("mobile")
		send_mess val("phone"),val("mess_text")
	end if
End Function
Function log1_add()
	if request("code")<>request.Cookies("AsaiCode") then
		rt2 0,"验证码不正确！"
		response.end
	end if
	dim sqla(10)
	vas2 "questionDescription",replace(val("questionDescription"),"'","‘")
	sqla(0)=cr2("[log1]","equipmentId,[declare],declareTele,questionDescription,typ,status")
	ret=execsw(sqla)
	rt ret
	
	vas "mess_text","您的工单提交成功，信息科将及时处理。"
	vas "phone",val("declareTele")
	send_mess val("phone"),val("mess_text")
	' response.end
	vas "mess_text","收到工单:"& val("questionDescription") & " 来自：" & val("declare") & val("declareTele")  &  "，请及时处理。"
	vas "phone",val("mobile")
	send_mess val("phone"),val("mess_text")
End Function


Function send_mess(phone,mess_text)
	dim sql,ret
	vas "date",Format_Time(now(),2)
	vas "mysource","1"

	vas "phone",phone
	vas "mess_text",mess_text
	sql=cr("mess","phone,mess_text,date,mysource")
	ret= Easp.Db.Execute(myg_conn, sql)
	send_mess=ret
end function
Function log1_upd()
	dim sqla(10),rc1
	vas "id",val(hr_1("id"))
	vas2 "questionDescription",replace(val("questionDescription"),"'","‘")

	sqla(0)=xg2("[log1]","status,typ,repairerId,questionDescription,fxpwd","id={id:int}" )
	vas "status",val(hr_1("status"))
	vas "repairerId",val(hr_1("repairerId"))
	s1 "select name1 as status from baseinfo where id={status:int}"
	s1 "select truename from [user] where id={repairerId:int}"
	
	vas "title",session("username") & "把状态改为：" & val("status") & "，把接单人改为：" & val("truename")
	vas "log1_id",val("id")
	if (rc("select id from tl_post where title={title} and log1_id={log1_id:int}" )=0) then
		vas "user_id",session("user_id")
		sqla(1)=cr("[tl_post]","title,log1_id,user_id")
	end if
	ret=execsw(sqla)
	rt ret

	if val("sendmess")="on" then
		s1 "select mobile from [user] where id={repairerId}"
		vas "mess_text","系统收到一条工单"& val("questionDescription") & "，请及时处理。"
		vas "phone",val("mobile")
		send_mess val("phone"),val("mess_text")
	end if
End Function
Function prn_upd()
	dim sqla(10),rc1
	vas "id",val(hr_1("id"))
	vas "machineNo",val(hr_1("machineNo"))
	rc1= rc("select id from [equipment] where machineNo={machineNo}")
	if rc1>1 then
		rt 0,"machineNo 机器号" & val(hr_1("machineNo")) & " 重复"
	else
		sqla(0)=xg2("[equipment]","department,[local],machineNo,equipmentTypeId,ipadr","id={id:int}" )
		ret=execsw(sqla)
		rt ret
	end if
End Function
Function equipmentType_del()
	dim ret
	ret = Easp.Db.Del("[equipmentType]","id={id:int}")
	rt ret
End Function
Function equipmentType_upd()
	dim sqla(10),rc1
	vas "id",val(hr_1("id"))
	rc1= rc("select id from [equipmentType] where equipmentName={equipmentName}")
	if rc1>1 then
		rt 0,"equipmentName 打印机型号" & val(hr_1("equipmentName")) & " 重复"
	else
		sqla(0)=xg2("[equipmentType]","equipmentName,typ","id={id:int}")
		ret=execsw(sqla)
		rt ret		
	end if	
End Function
Function equipmentType_add()
	dim sqla(10),rc1
	rc1= rc("select id from [equipmentType] where equipmentName={equipmentName}")
	if rc1=1 then
		rt 0,"equipmentName 打印机型号" & val(hr_1("equipmentName")) & " 重复"
	else
		sqla(0)=cr2("[equipmentType]","equipmentName,typ")
		ret=execsw(sqla)
		rt ret		
	end if	
End Function
Function equipmentType_l()
	dim sql,fields
	sql="select * from equipmentType  where (1=1)"
	if val("equipmentType_search")<>"" then
		vas "likeKey" ,"%{=equipmentType_search}%"
		sql=replace(sql,"1=1","equipmentName like {likeKey}")
	end if
	qry2json(sql)
End Function
Function test()
	dim sql,arr
	sql="select questionDescription from log1 where questionDescription like '*''*'"
	' arr= sql2arr(sql)
	' sql="update log1 set questionDescription=replace(questionDescription,'''','’') where questionDescription like '*''*'"
	' execsw sql

end function

Function log1_sum()
	dim sql
	easp.db.del "temp_sum1","1=1"
	sql= "select distinct truename from v_log1"
	gen_temp_sum0 sql
	
	sql="select truename,count(id) as cnt1 from v_log1 where status=899 group by truename"
	gen_temp_sum sql,"cnt1"

	sql="select truename,count(id) as cnt2 from v_log1 where status=900 group by truename"
	gen_temp_sum sql,"cnt2"

	sql="select truename,count(id) as cnt2 from v_log1 where status=1032 group by truename"
	gen_temp_sum sql,"cnt3"	
	
	sql="select * from temp_sum1 order by cnt1 desc"
	qry2json(sql)
End Function
Function gen_temp_sum0(sql)
	dim arr,i,maxcol,maxrow,j
	arr=sql2arr(sql)
	maxcol=ubound(arr,1)
	maxrow=ubound(arr,2)

	for i=0 to maxrow
		for j=0 to maxcol
			vas "truename",arr(j,i)
			sql=cr("temp_sum1","truename")
			execsw sql
		next
	next
End function

Function gen_temp_sum(sql,fieldn)
	dim arr,maxcol,maxrow,i,j
	arr=sql2arr(sql)
	maxcol=ubound(arr,1)
	maxrow=ubound(arr,2)
	for i=0 to maxrow
		vas "truename",arr(0,i)
		vas fieldn,arr(1,i)
		sql=xg("temp_sum1",fieldn,"truename={truename}")
		execsw sql
	next
End function


Function log1_l()
	dim sql,fields,tn
	tn="log1"
	sql="select id,equipmentId,repairerId,questionDescription,[declare],declareTele,submitTime,[status],name1,equipmentname,typ,typ_name,repairerId,truename from v_log1  where (1=1) and (2=2) and (3=3) and (5=5) and (6=6) order by id desc"
	if val(tn & "_search")<>"" then
		vas "likeKey" ,"%{=log1_search}%"
		sql=replace(sql,"1=1","questionDescription like {likeKey} or truename like {likeKey}" )
	end if
	if val("typ")<>"" then
		sql=replace(sql,"2=2","typ = {typ}")
	end if
	if val("status")<>"" then
		sql=replace(sql,"3=3","status = {status}")
	end if
	if val("sd")<>"" and val("ed")<>"" then
		sql=replace(sql,"5=5","submitTime >= #"& val("sd")&" 00:00:00# "& " and " & "submitTime<=#"&val("ed") & " 23:59:59#")
	else
		vas "sd",Format_Time(now()-5,2)
		vas "ed",Format_Time(now(),2)
		sql=replace(sql,"5=5","submitTime >= #"& val("sd")&" 00:00:00# "& " and " & "submitTime<=#"&val("ed") & " 23:59:59#")
	end if
	if val("repairerId")="" then
		' vas "repairerId",session("user_id")
		' sql=replace(sql,"6=6","repairerId = {repairerId}")
	else
		sql=replace(sql,"6=6","repairerId = {repairerId}")
	end if
	qry2json(sql)
End Function

Function prn_l()
	dim sql,fields
	sql="select id,department,[local],machineNo,equipmentTypeId,equipmentName,ipadr from v_prn  where (1=1) and (2=2)"
	if val("prn_search")<>"" then
		vas "likeKey" ,"%{=prn_search}%"
		sql=replace(sql,"1=1","department like {likeKey}")
	end if
	if val("typ")<>"" then
		sql=replace(sql,"2=2","typ = {typ}")
	else
        s1 "select id as typ from baseinfo where mode='设备类型'"
		sql=replace(sql,"2=2","typ = {typ}")
	end if

	qry2json(sql)
End Function
Function prj_del_sel()
	dim result,ob,i,ids,ret
	Set ob = toArray(json)
	For i=0 To ob.Count-1
		easp.var("id")=ob(i)("id")
		ret = Easp.Db.del("prj","id={id:int}")
	next
	Set ob = Nothing
End Function

Function getCheckData()
	dim result,ob,i,ids
	Set ob = toArray(json)
	For i=0 To ob.Count-1
	  ids=ids&ob(i)("ID") & "," 
	next
	easp.var("ids")=left(ids,len(ids)-1)
	Set ob = Nothing	
	result=easp.db.del("jf","id in ({ids})")
End Function
Function batchQrjf()
	dim result,ob,i,ids,ret
	Set ob = toArray(json)
	For i=0 To ob.Count-1
		' ids=ids&ob(i)("ID") & "," 
		easp.var("id")=ob(i)("ID")
		set rs=easp.db.sel("select qrjf from [jf] where id={id}")
		if rs("qrjf")=0 then
			ret=Easp.Db.Upd ("[jf]","qrjf=1","id={id}")    	
		end if
	next
	Set ob = Nothing
End Function
%>